#include "HEK1008.h"
#include "user_define.h"
#include "main.h"
#include "lib.h"
#define HEK1008_TX_ID_01 0x1899E126
#define HEK1008_TX_ID_02 0x1899E127
#define HEK1008_TX_ID_03 0x1899E128
#define HEK1008_TX_ID_04 0x1899E129

uint8_t uc_key01_01 = 0;
uint8_t uc_key02_01 = 0;
uint8_t uc_key03_01 = 0;
uint8_t uc_key04_01 = 0;
uint8_t uc_key05_01 = 0;
uint8_t uc_key06_01 = 0;
uint8_t uc_key07_01 = 0;
uint8_t uc_key08_01 = 0;

uint8_t uc_key01_01_last = 0;
uint8_t uc_key02_01_last = 0;
uint8_t uc_key03_01_last = 0;
uint8_t uc_key04_01_last = 0;
uint8_t uc_key05_01_last = 0;
uint8_t uc_key06_01_last = 0;
uint8_t uc_key07_01_last = 0;
uint8_t uc_key08_01_last = 0;

uint8_t uc_key01_01_cmd = 0;
uint8_t uc_key02_01_cmd = 0;
uint8_t uc_key03_01_cmd = 0;
uint8_t uc_key04_01_cmd = 0;
uint8_t uc_key05_01_cmd = 0;
uint8_t uc_key06_01_cmd = 0;
uint8_t uc_key07_01_cmd = 0;
uint8_t uc_key08_01_cmd = 0;

uint8_t uc_key01_led_red_01   = 0;
uint8_t uc_key01_led_green_01 = 0;
uint8_t uc_key01_led_blue_01  = 0;

uint8_t uc_key02_led_red_01   = 0;
uint8_t uc_key02_led_green_01 = 0;
uint8_t uc_key02_led_blue_01  = 0;

uint8_t uc_key03_led_red_01   = 0;
uint8_t uc_key03_led_green_01 = 0;
uint8_t uc_key03_led_blue_01  = 0;

uint8_t uc_key04_led_red_01   = 0;
uint8_t uc_key04_led_green_01 = 0;
uint8_t uc_key04_led_blue_01  = 0;

uint8_t uc_key05_led_red_01   = 0;
uint8_t uc_key05_led_green_01 = 0;
uint8_t uc_key05_led_blue_01  = 0;

uint8_t uc_key06_led_red_01   = 0;
uint8_t uc_key06_led_green_01 = 0;
uint8_t uc_key06_led_blue_01  = 0;

uint8_t uc_key07_led_red_01   = 0;
uint8_t uc_key07_led_green_01 = 0;
uint8_t uc_key07_led_blue_01  = 0;

uint8_t uc_key08_led_red_01   = 0;
uint8_t uc_key08_led_green_01 = 0;
uint8_t uc_key08_led_blue_01  = 0;
void hek1008_led_clear_01(void)
{
    uc_key01_led_red_01   = 0;
    uc_key01_led_green_01 = 0;
    uc_key01_led_blue_01  = 0;
    uc_key02_led_red_01   = 0;
    uc_key02_led_green_01 = 0;
    uc_key02_led_blue_01  = 0;
    uc_key03_led_red_01   = 0;
    uc_key03_led_green_01 = 0;
    uc_key03_led_blue_01  = 0;
    uc_key04_led_red_01   = 0;
    uc_key04_led_green_01 = 0;
    uc_key04_led_blue_01  = 0;
    uc_key05_led_red_01   = 0;
    uc_key05_led_green_01 = 0;
    uc_key05_led_blue_01  = 0;
    uc_key06_led_red_01   = 0;
    uc_key06_led_green_01 = 0;
    uc_key06_led_blue_01  = 0;
    uc_key07_led_red_01   = 0;
    uc_key07_led_green_01 = 0;
    uc_key07_led_blue_01  = 0;
    uc_key08_led_red_01   = 0;
    uc_key08_led_green_01 = 0;
    uc_key08_led_blue_01  = 0;
}
uint8_t hek1008_led_init_01(void)
{
    uint8_t tReturn = 0;

    if(ul_tick_500us < TIME_OUT_30S)
    {
        uc_key01_led_red_01   = 1;
        uc_key01_led_green_01 = 1;
        uc_key01_led_blue_01  = 1;
        uc_key02_led_red_01   = 1;
        uc_key02_led_green_01 = 1;
        uc_key02_led_blue_01  = 1;
        uc_key03_led_red_01   = 1;
        uc_key03_led_green_01 = 1;
        uc_key03_led_blue_01  = 1;
        uc_key04_led_red_01   = 1;
        uc_key04_led_green_01 = 1;
        uc_key04_led_blue_01  = 1;
        uc_key05_led_red_01   = 1;
        uc_key05_led_green_01 = 1;
        uc_key05_led_blue_01  = 1;
        uc_key06_led_red_01   = 1;
        uc_key06_led_green_01 = 1;
        uc_key06_led_blue_01  = 1;
        uc_key07_led_red_01   = 1;
        uc_key07_led_green_01 = 1;
        uc_key07_led_blue_01  = 1;
        uc_key08_led_red_01   = 1;
        uc_key08_led_green_01 = 1;
        uc_key08_led_blue_01  = 1;
    }
    else
    {
        hek1008_led_clear_01();
        tReturn = 1;
    }
    return tReturn;
}
/**
 * @brief CAN接收
 */
uint32_t gCan0RxCnt     = 0;//CAN总线异常判断使用参数，每接收到1帧CAN报文就加1
uint32_t gCan0RxCntLast = 0;//与gCan0RxCnt参数配合使用

void hek1008_can0_rx_01(CAN_DATA_FORMAT_T data)
{
    if(data.id != HEK1008_RX_ID_01) return;

    if((data.rx_len > 8) || (data.rx_len == 0)) return;

    uc_key01_01 = (data.rx_data[0]>>0)&0x03;
    uc_key02_01 = (data.rx_data[0]>>2)&0x03;
    uc_key03_01 = (data.rx_data[0]>>4)&0x03;
    uc_key04_01 = (data.rx_data[0]>>6)&0x03;
    uc_key05_01 = (data.rx_data[1]>>0)&0x03;
    uc_key06_01 = (data.rx_data[1]>>2)&0x03;
    uc_key07_01 = (data.rx_data[1]>>4)&0x03;
    uc_key08_01 = (data.rx_data[1]>>6)&0x03;
}

void hek1008_key_01_redefine(void)
{
    Lib_LockUnlockDataHandle(&uc_key01_01_last,&uc_key01_01,&uc_key01_01_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key02_01_last,&uc_key02_01,&uc_key02_01_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key03_01_last,&uc_key03_01,&uc_key03_01_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key04_01_last,&uc_key04_01,&uc_key04_01_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key05_01_last,&uc_key05_01,&uc_key05_01_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key06_01_last,&uc_key06_01,&uc_key06_01_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key07_01_last,&uc_key07_01,&uc_key07_01_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key08_01_last,&uc_key08_01,&uc_key08_01_cmd,SelfLock);
}
uint32_t ul_key_01_cnt = 0;
uint32_t ul_key01_01_cnt = 0;
uint32_t ul_key02_01_cnt = 0;
uint32_t ul_key03_01_cnt = 0;
uint32_t ul_key04_01_cnt = 0;
uint32_t ul_key05_01_cnt = 0;
uint32_t ul_key06_01_cnt = 0;
uint32_t ul_key07_01_cnt = 0;
uint32_t ul_key08_01_cnt = 0;

uint8_t uc_key01_01_led_ctrl_cnt = 0;
uint8_t uc_key02_01_led_ctrl_cnt = 0;
uint8_t uc_key03_01_led_ctrl_cnt = 0;
uint8_t uc_key04_01_led_ctrl_cnt = 0;
uint8_t uc_key05_01_led_ctrl_cnt = 0;
uint8_t uc_key06_01_led_ctrl_cnt = 0;
uint8_t uc_key07_01_led_ctrl_cnt = 0;
uint8_t uc_key08_01_led_ctrl_cnt = 0;
/**
 * @brief 控制LED
 */
void hek1008_led_ctrl_01(void)
{
    if(uc_key01_01_cmd == 1) 
    {
        uc_key01_01_cmd = 0;
        ul_key01_01_cnt++;
        uc_key01_01_led_ctrl_cnt++;
        if(uc_key01_01_led_ctrl_cnt > 3) uc_key01_01_led_ctrl_cnt = 0;
    }
    if(uc_key01_01_led_ctrl_cnt == 1) 
    {
        uc_key01_led_red_01 = 1;
        uc_key01_led_green_01 = 0;
        uc_key01_led_blue_01 = 0;
    }
    else if(uc_key01_01_led_ctrl_cnt == 2)
    {
        uc_key01_led_red_01 = 0;
        uc_key01_led_green_01 = 1;
        uc_key01_led_blue_01 = 0;
    }
    else if(uc_key01_01_led_ctrl_cnt == 3)
    {
        uc_key01_led_red_01 = 0;
        uc_key01_led_green_01 = 0;
        uc_key01_led_blue_01 = 1;
    }
    else
    {
        uc_key01_led_red_01 = 0;
        uc_key01_led_green_01 = 0;
        uc_key01_led_blue_01 = 0;
    }
    if(uc_key02_01_cmd == 1)
    {
        uc_key02_01_cmd = 0;
        ul_key02_01_cnt++;
        uc_key02_01_led_ctrl_cnt++; 
        if(uc_key02_01_led_ctrl_cnt > 3) uc_key02_01_led_ctrl_cnt = 0;
    }
    if(uc_key02_01_led_ctrl_cnt == 1)
    {
        uc_key02_led_red_01 = 1;
        uc_key02_led_green_01 = 0;
        uc_key02_led_blue_01 = 0;
    }
    else if(uc_key02_01_led_ctrl_cnt == 2)
    {
        uc_key02_led_red_01 = 0;
        uc_key02_led_green_01 = 1;
        uc_key02_led_blue_01 = 0;
    }
    else if(uc_key02_01_led_ctrl_cnt == 3)
    {
        uc_key02_led_red_01 = 0;
        uc_key02_led_green_01 = 0;
        uc_key02_led_blue_01 = 1;
    }
    else
    {
        uc_key02_led_red_01 = 0;
        uc_key02_led_green_01 = 0;
        uc_key02_led_blue_01 = 0;

    }
    if(uc_key03_01_cmd == 1)
    {
        uc_key03_01_cmd = 0;
        ul_key03_01_cnt++;
        uc_key03_01_led_ctrl_cnt++;
        if(uc_key03_01_led_ctrl_cnt > 3) uc_key03_01_led_ctrl_cnt = 0; 
    }
    if(uc_key03_01_led_ctrl_cnt == 1)
    {
        uc_key03_led_red_01 = 1;
        uc_key03_led_green_01 = 0;
        uc_key03_led_blue_01 = 0;
    }
    else if(uc_key03_01_led_ctrl_cnt == 2)
    {
        uc_key03_led_red_01 = 0;
        uc_key03_led_green_01 = 1;
        uc_key03_led_blue_01 = 0;
    }
    else if(uc_key03_01_led_ctrl_cnt == 3)
    {
        uc_key03_led_red_01 = 0;
        uc_key03_led_green_01 = 0;
        uc_key03_led_blue_01 = 1;
    }
    else
    {
        uc_key03_led_red_01 = 0;
        uc_key03_led_green_01 = 0;
        uc_key03_led_blue_01 = 0;
    }
    if(uc_key04_01_cmd == 1)
    {
        uc_key04_01_cmd = 0;
        ul_key04_01_cnt++;
        uc_key04_01_led_ctrl_cnt++;
        if(uc_key04_01_led_ctrl_cnt > 3) uc_key04_01_led_ctrl_cnt = 0; 
    }
    if(uc_key04_01_led_ctrl_cnt == 1)
    {
        uc_key04_led_red_01 = 1;
        uc_key04_led_green_01 = 0;
        uc_key04_led_blue_01 = 0;
    }
    else if(uc_key04_01_led_ctrl_cnt == 2)
    {
        uc_key04_led_red_01 = 0;
        uc_key04_led_green_01 = 1;
        uc_key04_led_blue_01 = 0;
    }
    else if(uc_key04_01_led_ctrl_cnt == 3)
    {
        uc_key04_led_red_01 = 0;
        uc_key04_led_green_01 = 0;
        uc_key04_led_blue_01 = 1;
    }
    else
    {
        uc_key04_led_red_01 = 0;
        uc_key04_led_green_01 = 0;
        uc_key04_led_blue_01 = 0;
    }
    if(uc_key05_01_cmd == 1)
    {
        uc_key05_01_cmd = 0;
        ul_key05_01_cnt++;
        uc_key05_01_led_ctrl_cnt++;
        if(uc_key05_01_led_ctrl_cnt > 3) uc_key05_01_led_ctrl_cnt = 0; 
    }
    if(uc_key05_01_led_ctrl_cnt == 1)
    {
        uc_key05_led_red_01 = 1;
        uc_key05_led_green_01 = 0;
        uc_key05_led_blue_01 = 0;
    }
    else if(uc_key05_01_led_ctrl_cnt == 2)
    {
        uc_key05_led_red_01 = 0;
        uc_key05_led_green_01 = 1;
        uc_key05_led_blue_01 = 0;
    }
    else if(uc_key05_01_led_ctrl_cnt == 3)
    {
        uc_key05_led_red_01 = 0;
        uc_key05_led_green_01 = 0;
        uc_key05_led_blue_01 = 1;
    }
    else
    {
        uc_key05_led_red_01 = 0;
        uc_key05_led_green_01 = 0;
        uc_key05_led_blue_01 = 0;
    }
    if(uc_key06_01_cmd == 1)
    {
        uc_key06_01_cmd = 0;
        ul_key06_01_cnt++;
        uc_key06_01_led_ctrl_cnt++;
        if(uc_key06_01_led_ctrl_cnt > 3) uc_key06_01_led_ctrl_cnt = 0; 
    }
    if(uc_key06_01_led_ctrl_cnt == 1)
    {
        uc_key06_led_red_01 = 1;
        uc_key06_led_green_01 = 0;
        uc_key06_led_blue_01 = 0;
    }
    else if(uc_key06_01_led_ctrl_cnt == 2)
    {
        uc_key06_led_red_01 = 0;
        uc_key06_led_green_01 = 1;
        uc_key06_led_blue_01 = 0;
    }
    else if(uc_key06_01_led_ctrl_cnt == 3)
    {
        uc_key06_led_red_01 = 0;
        uc_key06_led_green_01 = 0;
        uc_key06_led_blue_01 = 1;
    }
    else
    {
        uc_key06_led_red_01 = 0;
        uc_key06_led_green_01 = 0;
        uc_key06_led_blue_01 = 0;
    }
    if(uc_key07_01_cmd == 1)
    {
        uc_key07_01_cmd = 0;
        ul_key07_01_cnt++;
        uc_key07_01_led_ctrl_cnt++;
        if(uc_key07_01_led_ctrl_cnt > 3) uc_key07_01_led_ctrl_cnt = 0; 
    }
    if(uc_key07_01_led_ctrl_cnt == 1)
    {
        uc_key07_led_red_01 = 1;
        uc_key07_led_green_01 = 0;
        uc_key07_led_blue_01 = 0;
    }
    else if(uc_key07_01_led_ctrl_cnt == 2)
    {
        uc_key07_led_red_01 = 0;
        uc_key07_led_green_01 = 1;
        uc_key07_led_blue_01 = 0;
    }
    else if(uc_key07_01_led_ctrl_cnt == 3)
    {
        uc_key07_led_red_01 = 0;
        uc_key07_led_green_01 = 0;
        uc_key07_led_blue_01 = 1;
    }
    else
    {
        uc_key07_led_red_01 = 0;
        uc_key07_led_green_01 = 0;
        uc_key07_led_blue_01 = 0;
    }
    if(uc_key08_01_cmd == 1)
    {
        uc_key08_01_cmd = 0;
        ul_key08_01_cnt++;
        uc_key08_01_led_ctrl_cnt++;
        if(uc_key08_01_led_ctrl_cnt > 3) uc_key08_01_led_ctrl_cnt = 0; 
    }
    if(uc_key08_01_led_ctrl_cnt == 1)
    {
        uc_key08_led_red_01 = 1;
        uc_key08_led_green_01 = 0;
        uc_key08_led_blue_01 = 0;
    }
    else if(uc_key08_01_led_ctrl_cnt == 2)
    {
        uc_key08_led_red_01 = 0;
        uc_key08_led_green_01 = 1;
        uc_key08_led_blue_01 = 0;
    }
    else if(uc_key08_01_led_ctrl_cnt == 3)
    {
        uc_key08_led_red_01 = 0;
        uc_key08_led_green_01 = 0;
        uc_key08_led_blue_01 = 1;
    }
    else
    {
        uc_key08_led_red_01 = 0;
        uc_key08_led_green_01 = 0;
        uc_key08_led_blue_01 = 0;  
    }

    ul_key_01_cnt = ul_key01_01_cnt + ul_key02_01_cnt + ul_key03_01_cnt + ul_key04_01_cnt + ul_key05_01_cnt + ul_key06_01_cnt + ul_key07_01_cnt + ul_key08_01_cnt;
}
void hek1008_can0_tx_01(void)
{
    uint32_t id = HEK1008_TX_ID_01;
    uint8_t buf[8] = { 0 };

    buf[0] = (uc_key01_led_red_01  <<0) | (uc_key01_led_green_01<<2) | (uc_key01_led_blue_01 <<4)|(uc_key02_led_red_01  <<6);
    buf[1] = (uc_key02_led_green_01<<0) | (uc_key02_led_blue_01 <<2) | (uc_key03_led_red_01  <<4)|(uc_key03_led_green_01<<6);
    buf[2] = (uc_key03_led_blue_01 <<0) | (uc_key04_led_red_01  <<2) | (uc_key04_led_green_01<<4)|(uc_key04_led_blue_01 <<6);
    buf[3] = (uc_key05_led_red_01  <<0) | (uc_key05_led_green_01<<2) | (uc_key05_led_blue_01 <<4)|(uc_key06_led_red_01  <<6);
    buf[4] = (uc_key06_led_green_01<<0) | (uc_key06_led_blue_01 <<2) | (uc_key07_led_red_01  <<4)|(uc_key07_led_green_01<<6);
    buf[5] = (uc_key07_led_blue_01 <<0) | (uc_key08_led_red_01  <<2) | (uc_key08_led_green_01<<4)|(uc_key08_led_blue_01 <<6);
    buf[6] = 0;
    buf[7] = 0;
    Can0_Data_Store_Fifo(id,buf,8);
}
uint8_t uc_hek1008_test_01_status = 0;
void hek1008_test_01(void)
{
    uint8_t temp = 0;
    switch(uc_hek1008_test_01_status)
    {
        case 0:
            temp = hek1008_led_init_01();
            if(temp == 1) uc_hek1008_test_01_status += 1;
            break;
        case 1:
            hek1008_key_01_redefine();
			hek1008_led_ctrl_01();
            break;
        default:
            break;
    }
}

uint8_t uc_key01_02 = 0;
uint8_t uc_key02_02 = 0;
uint8_t uc_key03_02 = 0;
uint8_t uc_key04_02 = 0;
uint8_t uc_key05_02 = 0;
uint8_t uc_key06_02 = 0;
uint8_t uc_key07_02 = 0;
uint8_t uc_key08_02 = 0;

uint8_t uc_key01_02_last = 0;
uint8_t uc_key02_02_last = 0;
uint8_t uc_key03_02_last = 0;
uint8_t uc_key04_02_last = 0;
uint8_t uc_key05_02_last = 0;
uint8_t uc_key06_02_last = 0;
uint8_t uc_key07_02_last = 0;
uint8_t uc_key08_02_last = 0;

uint8_t uc_key01_02_cmd = 0;
uint8_t uc_key02_02_cmd = 0;
uint8_t uc_key03_02_cmd = 0;
uint8_t uc_key04_02_cmd = 0;
uint8_t uc_key05_02_cmd = 0;
uint8_t uc_key06_02_cmd = 0;
uint8_t uc_key07_02_cmd = 0;
uint8_t uc_key08_02_cmd = 0;

uint8_t uc_key01_led_red_02   = 0;
uint8_t uc_key01_led_green_02 = 0;
uint8_t uc_key01_led_blue_02  = 0;

uint8_t uc_key02_led_red_02   = 0;
uint8_t uc_key02_led_green_02 = 0;
uint8_t uc_key02_led_blue_02  = 0;

uint8_t uc_key03_led_red_02   = 0;
uint8_t uc_key03_led_green_02 = 0;
uint8_t uc_key03_led_blue_02  = 0;

uint8_t uc_key04_led_red_02   = 0;
uint8_t uc_key04_led_green_02 = 0;
uint8_t uc_key04_led_blue_02  = 0;

uint8_t uc_key05_led_red_02   = 0;
uint8_t uc_key05_led_green_02 = 0;
uint8_t uc_key05_led_blue_02  = 0;

uint8_t uc_key06_led_red_02   = 0;
uint8_t uc_key06_led_green_02 = 0;
uint8_t uc_key06_led_blue_02  = 0;

uint8_t uc_key07_led_red_02   = 0;
uint8_t uc_key07_led_green_02 = 0;
uint8_t uc_key07_led_blue_02  = 0;

uint8_t uc_key08_led_red_02   = 0;
uint8_t uc_key08_led_green_02 = 0;
uint8_t uc_key08_led_blue_02  = 0;
void hek1008_led_clear_02(void)
{
    uc_key01_led_red_02   = 0;
    uc_key01_led_green_02 = 0;
    uc_key01_led_blue_02  = 0;
    uc_key02_led_red_02   = 0;
    uc_key02_led_green_02 = 0;
    uc_key02_led_blue_02  = 0;
    uc_key03_led_red_02   = 0;
    uc_key03_led_green_02 = 0;
    uc_key03_led_blue_02  = 0;
    uc_key04_led_red_02   = 0;
    uc_key04_led_green_02 = 0;
    uc_key04_led_blue_02  = 0;
    uc_key05_led_red_02   = 0;
    uc_key05_led_green_02 = 0;
    uc_key05_led_blue_02  = 0;
    uc_key06_led_red_02   = 0;
    uc_key06_led_green_02 = 0;
    uc_key06_led_blue_02  = 0;
    uc_key07_led_red_02   = 0;
    uc_key07_led_green_02 = 0;
    uc_key07_led_blue_02  = 0;
    uc_key08_led_red_02   = 0;
    uc_key08_led_green_02 = 0;
    uc_key08_led_blue_02  = 0;
}
uint8_t hek1008_led_init_02(void)
{
    uint8_t tReturn = 0;
    if(ul_tick_500us < TIME_OUT_30S)
    {
        uc_key01_led_red_02   = 1;
        uc_key01_led_green_02 = 1;
        uc_key01_led_blue_02  = 1;
        uc_key02_led_red_02   = 1;
        uc_key02_led_green_02 = 1;
        uc_key02_led_blue_02  = 1;
        uc_key03_led_red_02   = 1;
        uc_key03_led_green_02 = 1;
        uc_key03_led_blue_02  = 1;
        uc_key04_led_red_02   = 1;
        uc_key04_led_green_02 = 1;
        uc_key04_led_blue_02  = 1;
        uc_key05_led_red_02   = 1;
        uc_key05_led_green_02 = 1;
        uc_key05_led_blue_02  = 1;
        uc_key06_led_red_02   = 1;
        uc_key06_led_green_02 = 1;
        uc_key06_led_blue_02  = 1;
        uc_key07_led_red_02   = 1;
        uc_key07_led_green_02 = 1;
        uc_key07_led_blue_02  = 1;
        uc_key08_led_red_02   = 1;
        uc_key08_led_green_02 = 1;
        uc_key08_led_blue_02  = 1;
    }
    else
    {
        hek1008_led_clear_02();
        tReturn = 1;
    }
    return tReturn;
}
void hek1008_can0_rx_02(CAN_DATA_FORMAT_T data)
{
    if(data.id!= HEK1008_RX_ID_02) return;

    if((data.rx_len > 8) || (data.rx_len == 0)) return;

    uc_key01_02   = (data.rx_data[0]>>0)&0x01;
    uc_key02_02   = (data.rx_data[0]>>2)&0x01;
    uc_key03_02   = (data.rx_data[0]>>4)&0x01;
    uc_key04_02   = (data.rx_data[0]>>6)&0x01;
    uc_key05_02   = (data.rx_data[1]>>0)&0x01;
    uc_key06_02   = (data.rx_data[1]>>2)&0x01;
    uc_key07_02   = (data.rx_data[1]>>4)&0x01;
    uc_key08_02   = (data.rx_data[1]>>6)&0x01;
}
void hek1008_key_02_redefine(void)
{
    Lib_LockUnlockDataHandle(&uc_key01_02_last,&uc_key01_02,&uc_key01_02_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key02_02_last,&uc_key02_02,&uc_key02_02_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key03_02_last,&uc_key03_02,&uc_key03_02_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key04_02_last,&uc_key04_02,&uc_key04_02_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key05_02_last,&uc_key05_02,&uc_key05_02_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key06_02_last,&uc_key06_02,&uc_key06_02_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key07_02_last,&uc_key07_02,&uc_key07_02_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key08_02_last,&uc_key08_02,&uc_key08_02_cmd,SelfLock);
}

uint32_t ul_key_02_cnt = 0;
uint32_t ul_key01_02_cnt = 0;
uint32_t ul_key02_02_cnt = 0;
uint32_t ul_key03_02_cnt = 0;
uint32_t ul_key04_02_cnt = 0;
uint32_t ul_key05_02_cnt = 0;
uint32_t ul_key06_02_cnt = 0;
uint32_t ul_key07_02_cnt = 0;
uint32_t ul_key08_02_cnt = 0;

uint8_t uc_key01_02_led_ctrl_cnt = 0;
uint8_t uc_key02_02_led_ctrl_cnt = 0;
uint8_t uc_key03_02_led_ctrl_cnt = 0;
uint8_t uc_key04_02_led_ctrl_cnt = 0;
uint8_t uc_key05_02_led_ctrl_cnt = 0;
uint8_t uc_key06_02_led_ctrl_cnt = 0;
uint8_t uc_key07_02_led_ctrl_cnt = 0;
uint8_t uc_key08_02_led_ctrl_cnt = 0;

void hek1008_led_ctrl_02(void)
{
    if(uc_key01_02_cmd == 1)
    {
        uc_key01_02_cmd = 0;
        ul_key01_02_cnt++;
        uc_key01_02_led_ctrl_cnt++;
        if(uc_key01_02_led_ctrl_cnt > 3) uc_key01_02_led_ctrl_cnt = 0;	
    }
    if(uc_key01_02_led_ctrl_cnt == 1)
    {
        uc_key01_led_red_02 = 1;
        uc_key01_led_green_02 = 0;
        uc_key01_led_blue_02 = 0;
    }
    else if(uc_key01_02_led_ctrl_cnt == 2)
    {
        uc_key01_led_red_02 = 0;
        uc_key01_led_green_02 = 1;
        uc_key01_led_blue_02 = 0;
    }
    else if(uc_key01_02_led_ctrl_cnt == 3)
    {
        uc_key01_led_red_02 = 0;
        uc_key01_led_green_02 = 0;
        uc_key01_led_blue_02 = 1;
    }
    else
    {
        uc_key01_led_red_02 = 0;
        uc_key01_led_green_02 = 0;
        uc_key01_led_blue_02 = 0;
    }
    if(uc_key02_02_cmd == 1)
    {
        uc_key02_02_cmd = 0;
        ul_key02_02_cnt++;
        uc_key02_02_led_ctrl_cnt++;
        if(uc_key02_02_led_ctrl_cnt > 3) uc_key02_02_led_ctrl_cnt = 0;	
    }
    if(uc_key02_02_led_ctrl_cnt == 1)
    {
        uc_key02_led_red_02 = 1;
        uc_key02_led_green_02 = 0;
        uc_key02_led_blue_02 = 0;	
    }
    else if(uc_key02_02_led_ctrl_cnt == 2)
    {
        uc_key02_led_red_02 = 0;
        uc_key02_led_green_02 = 1;
        uc_key02_led_blue_02 = 0;	
    }
    else if(uc_key02_02_led_ctrl_cnt == 3)
    {
        uc_key02_led_red_02 = 0;
        uc_key02_led_green_02 = 0;
        uc_key02_led_blue_02 = 1;	
    }
    else
    {
        uc_key02_led_red_02 = 0;
        uc_key02_led_green_02 = 0;
        uc_key02_led_blue_02 = 0;		
    }
    if(uc_key03_02_cmd == 1)
    {
        uc_key03_02_cmd = 0;
        ul_key03_02_cnt++;
        uc_key03_02_led_ctrl_cnt++;
        if(uc_key03_02_led_ctrl_cnt > 3) uc_key03_02_led_ctrl_cnt = 0;	
    }
    if(uc_key03_02_led_ctrl_cnt == 1)
    {
        uc_key03_led_red_02 = 1;
        uc_key03_led_green_02 = 0;
        uc_key03_led_blue_02 = 0;	
    }
    else if(uc_key03_02_led_ctrl_cnt == 2)
    {
        uc_key03_led_red_02 = 0;
        uc_key03_led_green_02 = 1;
        uc_key03_led_blue_02 = 0;	
    }
    else if(uc_key03_02_led_ctrl_cnt == 3)
    {
        uc_key03_led_red_02 = 0;
        uc_key03_led_green_02 = 0;
        uc_key03_led_blue_02 = 1;	
    }
    else
    {
        uc_key03_led_red_02 = 0;
        uc_key03_led_green_02 = 0;
        uc_key03_led_blue_02 = 0;		
    }
    if(uc_key04_02_cmd == 1)
    {
        uc_key04_02_cmd = 0;
        ul_key04_02_cnt++;
        uc_key04_02_led_ctrl_cnt++;
        if(uc_key04_02_led_ctrl_cnt > 3) uc_key04_02_led_ctrl_cnt = 0;	
    }
    if(uc_key04_02_led_ctrl_cnt == 1)
    {
        uc_key04_led_red_02 = 1;
        uc_key04_led_green_02 = 0;
        uc_key04_led_blue_02 = 0;
    }
    else if(uc_key04_02_led_ctrl_cnt == 2)
    {
        uc_key04_led_red_02 = 0;
        uc_key04_led_green_02 = 1;
        uc_key04_led_blue_02 = 0;
    }
    else if(uc_key04_02_led_ctrl_cnt == 3)
    {
        uc_key04_led_red_02 = 0;
        uc_key04_led_green_02 = 0;
        uc_key04_led_blue_02 = 1;
    }
    else
    {
        uc_key04_led_red_02 = 0;
        uc_key04_led_green_02 = 0;
        uc_key04_led_blue_02 = 0;
    }
    if(uc_key05_02_cmd == 1)
    {
        uc_key05_02_cmd = 0;
        ul_key05_02_cnt++;
        uc_key05_02_led_ctrl_cnt++;
        if(uc_key05_02_led_ctrl_cnt > 3) uc_key05_02_led_ctrl_cnt = 0;	
    }
    if(uc_key05_02_led_ctrl_cnt == 1)
    {
        uc_key05_led_red_02 = 1;
        uc_key05_led_green_02 = 0;
        uc_key05_led_blue_02 = 0;
    }
    else if(uc_key05_02_led_ctrl_cnt == 2)
    {
        uc_key05_led_red_02 = 0;
        uc_key05_led_green_02 = 1;
        uc_key05_led_blue_02 = 0;
    }
    else if(uc_key05_02_led_ctrl_cnt == 3)
    {
        uc_key05_led_red_02 = 0;
        uc_key05_led_green_02 = 0;
        uc_key05_led_blue_02 = 1;
    }
    else
    {
        uc_key05_led_red_02 = 0;
        uc_key05_led_green_02 = 0;
        uc_key05_led_blue_02 = 0;
    }
    if(uc_key06_02_cmd == 1)
    {
        uc_key06_02_cmd = 0;
        ul_key06_02_cnt++;
        uc_key06_02_led_ctrl_cnt++;
        if(uc_key06_02_led_ctrl_cnt > 3) uc_key06_02_led_ctrl_cnt = 0;	
    }
    if(uc_key06_02_led_ctrl_cnt == 1)
    {
        uc_key06_led_red_02 = 1;
        uc_key06_led_green_02 = 0;
        uc_key06_led_blue_02 = 0;	
    }
    else if(uc_key06_02_led_ctrl_cnt == 2)
    {
        uc_key06_led_red_02 = 0;
        uc_key06_led_green_02 = 1;
        uc_key06_led_blue_02 = 0;	
    }
    else if(uc_key06_02_led_ctrl_cnt == 3)
    {
        uc_key06_led_red_02 = 0;
        uc_key06_led_green_02 = 0;
        uc_key06_led_blue_02 = 1;	
    }
    else
    {
        uc_key06_led_red_02 = 0;
        uc_key06_led_green_02 = 0;
        uc_key06_led_blue_02 = 0;
    }
    if(uc_key07_02_cmd == 1)
    {
        uc_key07_02_cmd = 0;
        ul_key07_02_cnt++;
        uc_key07_02_led_ctrl_cnt++;
        if(uc_key07_02_led_ctrl_cnt > 3) uc_key07_02_led_ctrl_cnt = 0;	
    }
    if(uc_key07_02_led_ctrl_cnt == 1)
    {
        uc_key07_led_red_02 = 1;
        uc_key07_led_green_02 = 0;
        uc_key07_led_blue_02 = 0;	
    }
    else if(uc_key07_02_led_ctrl_cnt == 2)
    {
        uc_key07_led_red_02 = 0;
        uc_key07_led_green_02 = 1;
        uc_key07_led_blue_02 = 0;	
    }
    else if(uc_key07_02_led_ctrl_cnt == 3)
    {
        uc_key07_led_red_02 = 0;
        uc_key07_led_green_02 = 0;
        uc_key07_led_blue_02 = 1;	
    }
    else
    {
        uc_key07_led_red_02 = 0;
        uc_key07_led_green_02 = 0;
        uc_key07_led_blue_02 = 0;	
    }
    if(uc_key08_02_cmd == 1)
    {
        uc_key08_02_cmd = 0;
        ul_key08_02_cnt++;
        uc_key08_02_led_ctrl_cnt++;
        if(uc_key08_02_led_ctrl_cnt > 3) uc_key08_02_led_ctrl_cnt = 0;	
    }
    if(uc_key08_02_led_ctrl_cnt == 1)
    {
        uc_key08_led_red_02 = 1;
        uc_key08_led_green_02 = 0;
        uc_key08_led_blue_02 = 0;	
    }
    else if(uc_key08_02_led_ctrl_cnt == 2)
    {
        uc_key08_led_red_02 = 0;
        uc_key08_led_green_02 = 1;
        uc_key08_led_blue_02 = 0;	
    }
    else if(uc_key08_02_led_ctrl_cnt == 3)
    {
        uc_key08_led_red_02 = 0;
        uc_key08_led_green_02 = 0;
        uc_key08_led_blue_02 = 1;	
    }
    else
    {
        uc_key08_led_red_02 = 0;
        uc_key08_led_green_02 = 0;
        uc_key08_led_blue_02 = 0;	
    }
    ul_key_02_cnt = ul_key01_02_cnt + ul_key02_02_cnt + ul_key03_02_cnt + ul_key04_02_cnt + ul_key05_02_cnt + ul_key06_02_cnt + ul_key07_02_cnt + ul_key08_02_cnt;
}
void hek1008_can0_tx_02(void)
{
    uint32_t id = HEK1008_TX_ID_02;
    uint8_t buf[8] = { 0 };
    buf[0] = (uc_key01_led_red_02  <<0) | (uc_key01_led_green_02<<2) | (uc_key01_led_blue_02 <<4)|(uc_key02_led_red_02  <<6);
    buf[1] = (uc_key02_led_green_02<<0) | (uc_key02_led_blue_02 <<2) | (uc_key03_led_red_02  <<4)|(uc_key03_led_green_02<<6);
    buf[2] = (uc_key03_led_blue_02 <<0) | (uc_key04_led_red_02  <<2) | (uc_key04_led_green_02<<4)|(uc_key04_led_blue_02 <<6);
    buf[3] = (uc_key05_led_red_02  <<0) | (uc_key05_led_green_02<<2) | (uc_key05_led_blue_02 <<4)|(uc_key06_led_red_02  <<6);
    buf[4] = (uc_key06_led_green_02<<0) | (uc_key06_led_blue_02 <<2) | (uc_key07_led_red_02  <<4)|(uc_key07_led_green_02<<6);
    buf[5] = (uc_key07_led_blue_02 <<0) | (uc_key08_led_red_02  <<2) | (uc_key08_led_green_02<<4)|(uc_key08_led_blue_02 <<6);
    buf[6] = 0;
    buf[7] = 0;
    Can0_Data_Store_Fifo(id,buf,8);
}
uint8_t uc_hek1008_test_02_status = 0;
void hek1008_test_02(void)
{
    uint8_t temp = 0;
    switch(uc_hek1008_test_02_status)
    {
        case 0:
            temp = hek1008_led_init_02();
            if(temp == 1) uc_hek1008_test_02_status += 1;
            break;
        case 1:
            hek1008_key_02_redefine();
            hek1008_led_ctrl_02();
            break;
        default:
        break;
    }
}
uint8_t uc_key01_03 = 0;
uint8_t uc_key02_03 = 0;
uint8_t uc_key03_03 = 0;
uint8_t uc_key04_03 = 0;
uint8_t uc_key05_03 = 0;
uint8_t uc_key06_03 = 0;
uint8_t uc_key07_03 = 0;
uint8_t uc_key08_03 = 0;

uint8_t uc_key01_03_last = 0;
uint8_t uc_key02_03_last = 0;
uint8_t uc_key03_03_last = 0;
uint8_t uc_key04_03_last = 0;
uint8_t uc_key05_03_last = 0;
uint8_t uc_key06_03_last = 0;
uint8_t uc_key07_03_last = 0;
uint8_t uc_key08_03_last = 0;

uint8_t uc_key01_03_cmd = 0;
uint8_t uc_key02_03_cmd = 0;
uint8_t uc_key03_03_cmd = 0;
uint8_t uc_key04_03_cmd = 0;
uint8_t uc_key05_03_cmd = 0;
uint8_t uc_key06_03_cmd = 0;
uint8_t uc_key07_03_cmd = 0;
uint8_t uc_key08_03_cmd = 0;

uint8_t uc_key01_led_red_03   = 0;
uint8_t uc_key01_led_green_03 = 0;
uint8_t uc_key01_led_blue_03  = 0;

uint8_t uc_key02_led_red_03   = 0;
uint8_t uc_key02_led_green_03 = 0;
uint8_t uc_key02_led_blue_03  = 0;

uint8_t uc_key03_led_red_03   = 0;
uint8_t uc_key03_led_green_03 = 0;
uint8_t uc_key03_led_blue_03  = 0;

uint8_t uc_key04_led_red_03   = 0;
uint8_t uc_key04_led_green_03 = 0;
uint8_t uc_key04_led_blue_03  = 0;

uint8_t uc_key05_led_red_03   = 0;
uint8_t uc_key05_led_green_03 = 0;
uint8_t uc_key05_led_blue_03  = 0;

uint8_t uc_key06_led_red_03   = 0;
uint8_t uc_key06_led_green_03 = 0;
uint8_t uc_key06_led_blue_03  = 0;

uint8_t uc_key07_led_red_03   = 0;
uint8_t uc_key07_led_green_03 = 0;
uint8_t uc_key07_led_blue_03  = 0;

uint8_t uc_key08_led_red_03   = 0;
uint8_t uc_key08_led_green_03 = 0;
uint8_t uc_key08_led_blue_03  = 0;

void hek1008_led_clear_03(void)
{
    uc_key01_led_red_03   = 0;
    uc_key01_led_green_03 = 0;
    uc_key01_led_blue_03  = 0;

    uc_key02_led_red_03   = 0;
    uc_key02_led_green_03 = 0;
    uc_key02_led_blue_03  = 0;

    uc_key03_led_red_03   = 0;
    uc_key03_led_green_03 = 0;
    uc_key03_led_blue_03  = 0;

    uc_key04_led_red_03   = 0;
    uc_key04_led_green_03 = 0;
    uc_key04_led_blue_03  = 0;

    uc_key05_led_red_03   = 0;
    uc_key05_led_green_03 = 0;
    uc_key05_led_blue_03  = 0;

    uc_key06_led_red_03   = 0;
    uc_key06_led_green_03 = 0;
    uc_key06_led_blue_03  = 0;

    uc_key07_led_red_03   = 0;
    uc_key07_led_green_03 = 0;
    uc_key07_led_blue_03  = 0;

    uc_key08_led_red_03   = 0;
    uc_key08_led_green_03 = 0;
    uc_key08_led_blue_03  = 0;
}
uint8_t hek1008_led_init_03(void)
{
    uint8_t tReturn = 0;
    if(ul_tick_500us < TIME_OUT_30S)
    {
        uc_key01_led_red_03   = 1;
        uc_key01_led_green_03 = 1;
        uc_key01_led_blue_03  = 1;
        uc_key02_led_red_03   = 1;
        uc_key02_led_green_03 = 1;
        uc_key02_led_blue_03  = 1;
        uc_key03_led_red_03   = 1;
        uc_key03_led_green_03 = 1;
        uc_key03_led_blue_03  = 1;
        uc_key04_led_red_03   = 1;
        uc_key04_led_green_03 = 1;
        uc_key04_led_blue_03  = 1;
        uc_key05_led_red_03   = 1;
        uc_key05_led_green_03 = 1;
        uc_key05_led_blue_03  = 1;
        uc_key06_led_red_03   = 1;
        uc_key06_led_green_03 = 1;
        uc_key06_led_blue_03  = 1;
        uc_key07_led_red_03   = 1;
        uc_key07_led_green_03 = 1;
        uc_key07_led_blue_03  = 1;
        uc_key08_led_red_03   = 1;
        uc_key08_led_green_03 = 1;
        uc_key08_led_blue_03  = 1;
    }
    else
    {
        hek1008_led_clear_03();
        tReturn = 1;
    }
    return tReturn;
}
void hek1008_can0_rx_03(CAN_DATA_FORMAT_T data)
{
    if(data.id != HEK1008_RX_ID_03) return;
    if((data.rx_len > 8) || (data.rx_len == 0)) return;

    uc_key01_03 = (data.rx_data[0]>>0) & 0x03;
    uc_key02_03 = (data.rx_data[0]>>2) & 0x03;
    uc_key03_03 = (data.rx_data[0]>>4) & 0x03;
    uc_key04_03 = (data.rx_data[0]>>6) & 0x03;
    uc_key05_03 = (data.rx_data[1]>>0) & 0x03;
    uc_key06_03 = (data.rx_data[1]>>2) & 0x03;
    uc_key07_03 = (data.rx_data[1]>>4) & 0x03;
    uc_key08_03 = (data.rx_data[1]>>6) & 0x03;
}
void hek1008_key_03_redefine(void)
{
    Lib_LockUnlockDataHandle(&uc_key01_03_last, &uc_key01_03,&uc_key01_03_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key02_03_last, &uc_key02_03,&uc_key02_03_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key03_03_last, &uc_key03_03,&uc_key03_03_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key04_03_last, &uc_key04_03,&uc_key04_03_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key05_03_last, &uc_key05_03,&uc_key05_03_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key06_03_last, &uc_key06_03,&uc_key06_03_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key07_03_last, &uc_key07_03,&uc_key07_03_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key08_03_last, &uc_key08_03,&uc_key08_03_cmd,SelfLock);
}

uint32_t ul_key_03_cnt = 0;
uint32_t ul_key01_03_cnt = 0;
uint32_t ul_key02_03_cnt = 0;
uint32_t ul_key03_03_cnt = 0;
uint32_t ul_key04_03_cnt = 0;
uint32_t ul_key05_03_cnt = 0;
uint32_t ul_key06_03_cnt = 0;
uint32_t ul_key07_03_cnt = 0;
uint32_t ul_key08_03_cnt = 0;

uint8_t uc_key01_03_led_ctrl_cnt = 0;
uint8_t uc_key02_03_led_ctrl_cnt = 0;
uint8_t uc_key03_03_led_ctrl_cnt = 0;
uint8_t uc_key04_03_led_ctrl_cnt = 0;
uint8_t uc_key05_03_led_ctrl_cnt = 0;
uint8_t uc_key06_03_led_ctrl_cnt = 0;
uint8_t uc_key07_03_led_ctrl_cnt = 0;
uint8_t uc_key08_03_led_ctrl_cnt = 0;

void hek1008_led_ctrl_03(void)
{
    if(uc_key01_03_cmd == 1)
    {
        uc_key01_03_cmd = 0;
        ul_key01_03_cnt++;
        uc_key01_03_led_ctrl_cnt++;
        if(uc_key01_03_led_ctrl_cnt > 3) uc_key01_03_led_ctrl_cnt = 0;
    }
    if(uc_key01_03_led_ctrl_cnt == 1)
    {
        uc_key01_led_red_03   = 1;
        uc_key01_led_green_03 = 0;
        uc_key01_led_blue_03  = 0;
    }
    else if(uc_key01_03_led_ctrl_cnt == 2)
    {
        uc_key01_led_red_03   = 0;
        uc_key01_led_green_03 = 1;
        uc_key01_led_blue_03  = 0;	
    }
    else if(uc_key01_03_led_ctrl_cnt == 3)
    {
        uc_key01_led_red_03   = 0;
        uc_key01_led_green_03 = 0;
        uc_key01_led_blue_03  = 1;
    }
    else
    {
        uc_key01_led_red_03   = 0;
        uc_key01_led_green_03 = 0;
        uc_key01_led_blue_03  = 0;
    }
    if(uc_key02_03_cmd == 1)
    {
        uc_key02_03_cmd = 0;
        ul_key02_03_cnt++;
        uc_key02_03_led_ctrl_cnt++;
        if(uc_key02_03_led_ctrl_cnt > 3) uc_key02_03_led_ctrl_cnt = 0;	
    }
    if(uc_key02_03_led_ctrl_cnt == 1)
    {
        uc_key02_led_red_03   = 1;
        uc_key02_led_green_03 = 0;
        uc_key02_led_blue_03  = 0;
    }
    else if(uc_key02_03_led_ctrl_cnt == 2)
    {
        uc_key02_led_red_03   = 0;
        uc_key02_led_green_03 = 1;
        uc_key02_led_blue_03  = 0;
    }
    else if(uc_key02_03_led_ctrl_cnt == 3)
    {
        uc_key02_led_red_03   = 0;
        uc_key02_led_green_03 = 0;
        uc_key02_led_blue_03  = 1;
    }
    else
    {
        uc_key02_led_red_03   = 0;
        uc_key02_led_green_03 = 0;
        uc_key02_led_blue_03  = 0;
    }
    if(uc_key03_03_cmd == 1)
    {
        uc_key03_03_cmd = 0;
        ul_key03_03_cnt++;
        uc_key03_03_led_ctrl_cnt++;
        if(uc_key03_03_led_ctrl_cnt > 3) uc_key03_03_led_ctrl_cnt = 0;	
    }
    if(uc_key03_03_led_ctrl_cnt == 1)
    {
        uc_key03_led_red_03   = 1;
        uc_key03_led_green_03 = 0;
        uc_key03_led_blue_03  = 0;	
    }
    else if(uc_key03_03_led_ctrl_cnt == 2)
    {
        uc_key03_led_red_03   = 0;
        uc_key03_led_green_03 = 1;
        uc_key03_led_blue_03  = 0;
    }
    else if(uc_key03_03_led_ctrl_cnt == 3)
    {
        uc_key03_led_red_03   = 0;
        uc_key03_led_green_03 = 0;
        uc_key03_led_blue_03  = 1;
    }
    else
    {
        uc_key03_led_red_03   = 0;
        uc_key03_led_green_03 = 0;
        uc_key03_led_blue_03  = 0;
    }
    if(uc_key04_03_cmd == 1)
    {
        uc_key04_03_cmd = 0;
        ul_key04_03_cnt++;
        uc_key04_03_led_ctrl_cnt++;
        if(uc_key04_03_led_ctrl_cnt > 3) uc_key04_03_led_ctrl_cnt = 0;	
    }
    if(uc_key04_03_led_ctrl_cnt == 1)
    {
        uc_key04_led_red_03   = 1;
        uc_key04_led_green_03 = 0;
        uc_key04_led_blue_03  = 0;	
    }
    else if(uc_key04_03_led_ctrl_cnt == 2)
    {
        uc_key04_led_red_03   = 0;
        uc_key04_led_green_03 = 1;
        uc_key04_led_blue_03  = 0;	
    }
    else if(uc_key04_03_led_ctrl_cnt == 3)
    {
        uc_key04_led_red_03   = 0;
        uc_key04_led_green_03 = 0;
        uc_key04_led_blue_03  = 1;
    }
    else
    {
        uc_key04_led_red_03   = 0;
        uc_key04_led_green_03 = 0;
        uc_key04_led_blue_03  = 0;
    }
    if(uc_key05_03_cmd == 1)
    {
        uc_key05_03_cmd = 0;
        ul_key05_03_cnt++;
        uc_key05_03_led_ctrl_cnt++;
        if(uc_key05_03_led_ctrl_cnt > 3) uc_key05_03_led_ctrl_cnt = 0;	
    }
    if(uc_key05_03_led_ctrl_cnt == 1)
    {
        uc_key05_led_red_03   = 1;
        uc_key05_led_green_03 = 0;
        uc_key05_led_blue_03  = 0;
    }
    else if(uc_key05_03_led_ctrl_cnt == 2)
    {
        uc_key05_led_red_03   = 0;
        uc_key05_led_green_03 = 1;
        uc_key05_led_blue_03  = 0;
    }
    else if(uc_key05_03_led_ctrl_cnt == 3)
    {
        uc_key05_led_red_03   = 0;
        uc_key05_led_green_03 = 0;
        uc_key05_led_blue_03  = 1;
    }
    else
    {
        uc_key05_led_red_03   = 0;
        uc_key05_led_green_03 = 0;
        uc_key05_led_blue_03  = 0;
    }
    if(uc_key06_03_cmd == 1)
    {
        uc_key06_03_cmd = 0;
        ul_key06_03_cnt++;
        uc_key06_03_led_ctrl_cnt++;
        if(uc_key06_03_led_ctrl_cnt > 3) uc_key06_03_led_ctrl_cnt = 0;	
    }
    if(uc_key06_03_led_ctrl_cnt == 1)
    {
        uc_key06_led_red_03   = 1;
        uc_key06_led_green_03 = 0;
        uc_key06_led_blue_03  = 0;	
    }
    else if(uc_key06_03_led_ctrl_cnt == 2)
    {
        uc_key06_led_red_03   = 0;
        uc_key06_led_green_03 = 1;
        uc_key06_led_blue_03  = 0;	
    }
    else if(uc_key06_03_led_ctrl_cnt == 3)
    {
        uc_key06_led_red_03   = 0;
        uc_key06_led_green_03 = 0;
        uc_key06_led_blue_03  = 1;	
    }
    else
    {
        uc_key06_led_red_03   = 0;
        uc_key06_led_green_03 = 0;
        uc_key06_led_blue_03  = 0;
    }
    if(uc_key07_03_cmd == 1)
    {
        uc_key07_03_cmd = 0;
        ul_key07_03_cnt++;
        uc_key07_03_led_ctrl_cnt++;
        if(uc_key07_03_led_ctrl_cnt > 3) uc_key07_03_led_ctrl_cnt = 0;	
    }
    if(uc_key07_03_led_ctrl_cnt == 1)
    {
        uc_key07_led_red_03   = 1;
        uc_key07_led_green_03 = 0;
        uc_key07_led_blue_03  = 0;    
    }
    else if(uc_key07_03_led_ctrl_cnt == 2)
    {
        uc_key07_led_red_03   = 0;
        uc_key07_led_green_03 = 1;
        uc_key07_led_blue_03  = 0;	
    }
    else if(uc_key07_03_led_ctrl_cnt == 3)
    {
        uc_key07_led_red_03   = 0;
        uc_key07_led_green_03 = 0;
        uc_key07_led_blue_03  = 1;	
    }
    else
    {
        uc_key07_led_red_03   = 0;
        uc_key07_led_green_03 = 0;
        uc_key07_led_blue_03  = 0;	
    }
    if(uc_key08_03_cmd == 1)
    {
        uc_key08_03_cmd = 0;
        ul_key08_03_cnt++;
        uc_key08_03_led_ctrl_cnt++;
        if(uc_key08_03_led_ctrl_cnt > 3) uc_key08_03_led_ctrl_cnt = 0;	
    }
    if(uc_key08_03_led_ctrl_cnt == 1)
    {
        uc_key08_led_red_03   = 1;
        uc_key08_led_green_03 = 0;
        uc_key08_led_blue_03  = 0;	
    }
    else if(uc_key08_03_led_ctrl_cnt == 2)
    {
        uc_key08_led_red_03   = 0;
        uc_key08_led_green_03 = 1;
        uc_key08_led_blue_03  = 0;	
    }
    else if(uc_key08_03_led_ctrl_cnt == 3)
    {
        uc_key08_led_red_03   = 0;
        uc_key08_led_green_03 = 0;
        uc_key08_led_blue_03  = 1;
    }
    else
    {
        uc_key08_led_red_03   = 0;
        uc_key08_led_green_03 = 0;
        uc_key08_led_blue_03  = 0;	
    }
    ul_key_03_cnt = ul_key01_03_cnt + ul_key02_03_cnt + ul_key03_03_cnt + ul_key04_03_cnt + ul_key05_03_cnt + ul_key06_03_cnt + ul_key07_03_cnt + ul_key08_03_cnt;
}
void hek1008_can0_tx_03(void)
{
    uint32_t id = HEK1008_TX_ID_03;
    uint8_t buf[8] = { 0 };
    buf[0] = (uc_key01_led_red_03  <<0) | (uc_key01_led_green_03<<2) | (uc_key01_led_blue_03 <<4)|(uc_key02_led_red_03  <<6);
    buf[1] = (uc_key02_led_green_03<<0) | (uc_key02_led_blue_03 <<2) | (uc_key03_led_red_03  <<4)|(uc_key03_led_green_03<<6);
    buf[2] = (uc_key03_led_blue_03 <<0) | (uc_key04_led_red_03  <<2) | (uc_key04_led_green_03<<4)|(uc_key04_led_blue_03 <<6);
    buf[3] = (uc_key05_led_red_03  <<0) | (uc_key05_led_green_03<<2) | (uc_key05_led_blue_03 <<4)|(uc_key06_led_red_03  <<6);
    buf[4] = (uc_key06_led_green_03<<0) | (uc_key06_led_blue_03 <<2) | (uc_key07_led_red_03  <<4)|(uc_key07_led_green_03<<6);
    buf[5] = (uc_key07_led_blue_03 <<0) | (uc_key08_led_red_03  <<2) | (uc_key08_led_green_03<<4)|(uc_key08_led_blue_03 <<6);
    buf[6] = 0;
    buf[7] = 0;
    Can0_Data_Store_Fifo(id,buf,8); 
}
uint8_t uc_hek1008_test_03_status = 0;
void hek1008_test_03(void)
{
    uint8_t temp = 0;
    switch(uc_hek1008_test_03_status)
    {
        case 0:
            temp = hek1008_led_init_03();
            if(temp == 1) uc_hek1008_test_03_status += 1;
            break;
        case 1:
            hek1008_key_03_redefine();
            hek1008_led_ctrl_03();
            break;
        default:
        break;
    }
}

uint8_t uc_key01_04 = 0;
uint8_t uc_key02_04 = 0;
uint8_t uc_key03_04 = 0;
uint8_t uc_key04_04 = 0;
uint8_t uc_key05_04 = 0;
uint8_t uc_key06_04 = 0;
uint8_t uc_key07_04 = 0;
uint8_t uc_key08_04 = 0;

uint8_t uc_key01_04_last = 0;
uint8_t uc_key02_04_last = 0;
uint8_t uc_key03_04_last = 0;
uint8_t uc_key04_04_last = 0;
uint8_t uc_key05_04_last = 0;
uint8_t uc_key06_04_last = 0;
uint8_t uc_key07_04_last = 0;
uint8_t uc_key08_04_last = 0;

uint8_t uc_key01_04_cmd = 0;
uint8_t uc_key02_04_cmd = 0;
uint8_t uc_key03_04_cmd = 0;
uint8_t uc_key04_04_cmd = 0;
uint8_t uc_key05_04_cmd = 0;
uint8_t uc_key06_04_cmd = 0;
uint8_t uc_key07_04_cmd = 0;
uint8_t uc_key08_04_cmd = 0;

uint8_t uc_key01_led_red_04   = 0;
uint8_t uc_key01_led_green_04 = 0;
uint8_t uc_key01_led_blue_04  = 0;

uint8_t uc_key02_led_red_04   = 0;
uint8_t uc_key02_led_green_04 = 0;
uint8_t uc_key02_led_blue_04  = 0;

uint8_t uc_key03_led_red_04   = 0;
uint8_t uc_key03_led_green_04 = 0;
uint8_t uc_key03_led_blue_04  = 0;

uint8_t uc_key04_led_red_04   = 0;
uint8_t uc_key04_led_green_04 = 0;
uint8_t uc_key04_led_blue_04  = 0;

uint8_t uc_key05_led_red_04   = 0;
uint8_t uc_key05_led_green_04 = 0;
uint8_t uc_key05_led_blue_04  = 0;

uint8_t uc_key06_led_red_04   = 0;
uint8_t uc_key06_led_green_04 = 0;
uint8_t uc_key06_led_blue_04  = 0;

uint8_t uc_key07_led_red_04   = 0;
uint8_t uc_key07_led_green_04 = 0;
uint8_t uc_key07_led_blue_04  = 0;

uint8_t uc_key08_led_red_04   = 0;
uint8_t uc_key08_led_green_04 = 0;
uint8_t uc_key08_led_blue_04  = 0;

void hek1008_led_clear_04(void)
{
    uc_key01_led_red_04   = 0;
    uc_key01_led_green_04 = 0;
    uc_key01_led_blue_04  = 0;
    uc_key02_led_red_04   = 0;
    uc_key02_led_green_04 = 0;
    uc_key02_led_blue_04  = 0;
    uc_key03_led_red_04   = 0;
    uc_key03_led_green_04 = 0;
    uc_key03_led_blue_04  = 0;
    uc_key04_led_red_04   = 0;
    uc_key04_led_green_04 = 0;
    uc_key04_led_blue_04  = 0;
    uc_key05_led_red_04   = 0;
    uc_key05_led_green_04 = 0;
    uc_key05_led_blue_04  = 0;
    uc_key06_led_red_04   = 0;
    uc_key06_led_green_04 = 0;
    uc_key06_led_blue_04  = 0;
    uc_key07_led_red_04   = 0;
    uc_key07_led_green_04 = 0;
    uc_key07_led_blue_04  = 0;
    uc_key08_led_red_04   = 0;
    uc_key08_led_green_04 = 0;
    uc_key08_led_blue_04  = 0;
}
uint8_t hek1008_led_init_04(void)
{
    uint8_t tReturn = 0;
    if(ul_tick_500us < TIME_OUT_30S)
    {
        uc_key01_led_red_04   = 1;
        uc_key01_led_green_04 = 1;
        uc_key01_led_blue_04  = 1;
        uc_key02_led_red_04   = 1;
        uc_key02_led_green_04 = 1;
        uc_key02_led_blue_04  = 1;
        uc_key03_led_red_04   = 1;
        uc_key03_led_green_04 = 1;
        uc_key03_led_blue_04  = 1;
        uc_key04_led_red_04   = 1;
        uc_key04_led_green_04 = 1;
        uc_key04_led_blue_04  = 1;
        uc_key05_led_red_04   = 1;
        uc_key05_led_green_04 = 1;
        uc_key05_led_blue_04  = 1;
        uc_key06_led_red_04   = 1;
        uc_key06_led_green_04 = 1;
        uc_key06_led_blue_04  = 1;
        uc_key07_led_red_04   = 1;
        uc_key07_led_green_04 = 1;
        uc_key07_led_blue_04  = 1;
        uc_key08_led_red_04   = 1;
        uc_key08_led_green_04 = 1;
        uc_key08_led_blue_04  = 1;
    }
    else
    {
        hek1008_led_clear_04();
        tReturn = 1;
    }
		return tReturn;
}

void hek1008_can0_rx_04(CAN_DATA_FORMAT_T data)
{
    if(data.id != HEK1008_RX_ID_04) return;
    if((data.rx_len > 8) || (data.rx_len == 0))return;

    uc_key01_04 = (data.rx_data[0]>>0) & 0x03;
    uc_key02_04 = (data.rx_data[0]>>2) & 0x03;
    uc_key03_04 = (data.rx_data[0]>>4) & 0x03;
    uc_key04_04 = (data.rx_data[0]>>6) & 0x03;
    uc_key05_04 = (data.rx_data[1]>>0) & 0x03;
    uc_key06_04 = (data.rx_data[1]>>2) & 0x03;
    uc_key07_04 = (data.rx_data[1]>>4) & 0x03;
    uc_key08_04 = (data.rx_data[1]>>6) & 0x03;
}
void hek1008_key_04_redefine(void)
{
    Lib_LockUnlockDataHandle(&uc_key01_04_last,&uc_key01_04,&uc_key02_04_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key02_04_last,&uc_key02_04,&uc_key02_04_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key03_04_last,&uc_key03_04,&uc_key03_04_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key04_04_last,&uc_key04_04,&uc_key04_04_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key05_04_last,&uc_key05_04,&uc_key05_04_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key06_04_last,&uc_key06_04,&uc_key06_04_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key07_04_last,&uc_key07_04,&uc_key07_04_cmd,SelfLock);
    Lib_LockUnlockDataHandle(&uc_key08_04_last,&uc_key08_04,&uc_key08_04_cmd,SelfLock);
}
uint32_t ul_key_04_cnt = 0;
uint32_t ul_key01_04_cnt = 0;
uint32_t ul_key02_04_cnt = 0;
uint32_t ul_key03_04_cnt = 0;
uint32_t ul_key04_04_cnt = 0;
uint32_t ul_key05_04_cnt = 0;
uint32_t ul_key06_04_cnt = 0;
uint32_t ul_key07_04_cnt = 0;
uint32_t ul_key08_04_cnt = 0;

uint8_t uc_key01_04_led_ctrl_cnt = 0;
uint8_t uc_key02_04_led_ctrl_cnt = 0;
uint8_t uc_key03_04_led_ctrl_cnt = 0;
uint8_t uc_key04_04_led_ctrl_cnt = 0;
uint8_t uc_key05_04_led_ctrl_cnt = 0;
uint8_t uc_key06_04_led_ctrl_cnt = 0;
uint8_t uc_key07_04_led_ctrl_cnt = 0;
uint8_t uc_key08_04_led_ctrl_cnt = 0;

void hek1008_led_ctrl_04(void)
{
    if(uc_key01_04_cmd == 1)
    {
        uc_key01_04_cmd = 0;
        ul_key01_04_cnt++;
        uc_key01_04_led_ctrl_cnt++;
        if(uc_key01_04_led_ctrl_cnt > 3) uc_key01_04_led_ctrl_cnt = 0;	
    }
    if(uc_key01_04_led_ctrl_cnt == 1)
    {
        uc_key01_led_red_04   = 1;
        uc_key01_led_green_04 = 0;
        uc_key01_led_blue_04  = 0;
    }
    else if(uc_key01_04_led_ctrl_cnt == 2)
    {
        uc_key01_led_red_04   = 0;
        uc_key01_led_green_04 = 1;
        uc_key01_led_blue_04  = 0;
    }
    else if(uc_key01_04_led_ctrl_cnt == 3)
    {
        uc_key01_led_red_04   = 0;
        uc_key01_led_green_04 = 0;
        uc_key01_led_blue_04  = 1;
    }
    else
    {
        uc_key01_led_red_04   = 0;
        uc_key01_led_green_04 = 0;
        uc_key01_led_blue_04  = 0;
    }
    if(uc_key02_04_cmd == 1)
    {
        uc_key02_04_cmd = 0;
        ul_key02_04_cnt++;
        uc_key02_04_led_ctrl_cnt++;
        if(uc_key02_04_led_ctrl_cnt > 3) uc_key02_04_led_ctrl_cnt = 0;	
    }
    if(uc_key02_04_led_ctrl_cnt == 1)
    {
        uc_key02_led_red_04   = 1;
        uc_key02_led_green_04 = 0;
        uc_key02_led_blue_04  = 0;	
    }
    else if(uc_key02_04_led_ctrl_cnt == 2)
    {
        uc_key02_led_red_04   = 0;
        uc_key02_led_green_04 = 1;
        uc_key02_led_blue_04  = 0;	
    }
    else if(uc_key02_04_led_ctrl_cnt == 3)
    {
        uc_key02_led_red_04   = 0;
        uc_key02_led_green_04 = 0;
        uc_key02_led_blue_04  = 1;	
    }
    else
    {
        uc_key02_led_red_04   = 0;
        uc_key02_led_green_04 = 0;
        uc_key02_led_blue_04  = 0;
    }
    if(uc_key03_04_cmd == 1)
    {
        uc_key03_04_cmd = 0;
        ul_key03_04_cnt++;
        uc_key03_04_led_ctrl_cnt++;
        if(uc_key03_04_led_ctrl_cnt > 3) uc_key03_04_led_ctrl_cnt = 0;	
    }
    if(uc_key03_04_led_ctrl_cnt == 1)
    {
        uc_key03_led_red_04   = 1;
        uc_key03_led_green_04 = 0;
        uc_key03_led_blue_04  = 0;	
    }
    else if(uc_key03_04_led_ctrl_cnt == 2)
    {
        uc_key03_led_red_04   = 0;
        uc_key03_led_green_04 = 1;
        uc_key03_led_blue_04  = 0;	
    }
    else if(uc_key03_04_led_ctrl_cnt == 3)
    {
        uc_key03_led_red_04   = 0;
        uc_key03_led_green_04 = 0;
        uc_key03_led_blue_04  = 1;
    }
    else
    {
        uc_key03_led_red_04   = 0;
        uc_key03_led_green_04 = 0;
        uc_key03_led_blue_04  = 0;
    }
    if(uc_key04_04_cmd == 1)
    {
        uc_key04_04_cmd = 0;
        ul_key04_04_cnt++;
        uc_key04_04_led_ctrl_cnt++;
        if(uc_key04_04_led_ctrl_cnt > 3) uc_key04_04_led_ctrl_cnt = 0;	
    }
    if(uc_key04_04_led_ctrl_cnt == 1)
    {
        uc_key04_led_red_04   = 1;
        uc_key04_led_green_04 = 0;
        uc_key04_led_blue_04  = 0;	
    }
    else if(uc_key04_04_led_ctrl_cnt == 2)
    {
        uc_key04_led_red_04   = 0;
        uc_key04_led_green_04 = 1;
        uc_key04_led_blue_04  = 0;	
    }
    else if(uc_key04_04_led_ctrl_cnt == 3)
    {
        uc_key04_led_red_04   = 0;
        uc_key04_led_green_04 = 0;
        uc_key04_led_blue_04  = 1;	
    }
    else
    {
        uc_key04_led_red_04   = 0;
        uc_key04_led_green_04 = 0;
        uc_key04_led_blue_04  = 0;
    }
    if(uc_key05_04_cmd == 1)
    {
        uc_key05_04_cmd = 0;
        ul_key05_04_cnt++;
        uc_key05_04_led_ctrl_cnt++;
        if(uc_key05_04_led_ctrl_cnt > 3) uc_key05_04_led_ctrl_cnt = 0;	
    }
    if(uc_key05_04_led_ctrl_cnt == 1)
    {
        uc_key05_led_red_04   = 1;
        uc_key05_led_green_04 = 0;
        uc_key05_led_blue_04  = 0;
    }
    else if(uc_key05_04_led_ctrl_cnt == 2)
    {
        uc_key05_led_red_04   = 0;
        uc_key05_led_green_04 = 1;
        uc_key05_led_blue_04  = 0;
    }
    else if(uc_key05_04_led_ctrl_cnt == 3)
    {
        uc_key05_led_red_04   = 0;
        uc_key05_led_green_04 = 0;
        uc_key05_led_blue_04  = 1;
    }
    else
    {
        uc_key05_led_red_04   = 0;
        uc_key05_led_green_04 = 0;
        uc_key05_led_blue_04  = 0;
    }
    if(uc_key06_04_cmd == 1)
    {
        uc_key06_04_cmd = 0;
        ul_key06_04_cnt++;
        uc_key06_04_led_ctrl_cnt++;
        if(uc_key06_04_led_ctrl_cnt > 3) uc_key06_04_led_ctrl_cnt = 0;	
    }
    if(uc_key06_04_led_ctrl_cnt == 1)
    {
        uc_key06_led_red_04   = 1;
        uc_key06_led_green_04 = 0;
        uc_key06_led_blue_04  = 0;	
    }
    else if(uc_key06_04_led_ctrl_cnt == 2)
    {
        uc_key06_led_red_04   = 0;
        uc_key06_led_green_04 = 1;
        uc_key06_led_blue_04  = 0;	
    }
    else if(uc_key06_04_led_ctrl_cnt == 3)
    {
        uc_key06_led_red_04   = 0;
        uc_key06_led_green_04 = 0;
        uc_key06_led_blue_04  = 1;	
    }
    else
    {
        uc_key06_led_red_04   = 0;
        uc_key06_led_green_04 = 0;
        uc_key06_led_blue_04  = 0;
    }
    if(uc_key07_04_cmd == 1)
    {
        uc_key07_04_cmd = 0;
        ul_key07_04_cnt++;
        uc_key07_04_led_ctrl_cnt++;
        if(uc_key07_04_led_ctrl_cnt > 3) uc_key07_04_led_ctrl_cnt = 0;	
    }
    if(uc_key07_04_led_ctrl_cnt == 1)
    {
        uc_key07_led_red_04   = 1;
        uc_key07_led_green_04 = 0;
        uc_key07_led_blue_04  = 0;	
    }
    else if(uc_key07_04_led_ctrl_cnt == 2)
    {
        uc_key07_led_red_04   = 0;
        uc_key07_led_green_04 = 1;
        uc_key07_led_blue_04  = 0;	
    }
    else if(uc_key07_04_led_ctrl_cnt == 3)
    {
        uc_key07_led_red_04   = 0;
        uc_key07_led_green_04 = 0;
        uc_key07_led_blue_04  = 1;	
    }
    else
    {
        uc_key07_led_red_04   = 0;
        uc_key07_led_green_04 = 0;
        uc_key07_led_blue_04  = 0;
    }
    if(uc_key08_04_cmd == 1)
    {
        uc_key08_04_cmd = 0;
        ul_key08_04_cnt++;
        uc_key08_04_led_ctrl_cnt++;
        if(uc_key08_04_led_ctrl_cnt > 3) uc_key08_04_led_ctrl_cnt = 0;	
    }
    if(uc_key08_04_led_ctrl_cnt == 1)
    {
        uc_key08_led_red_04   = 1;
        uc_key08_led_green_04 = 0;
        uc_key08_led_blue_04  = 0;	
    }
    else if(uc_key08_04_led_ctrl_cnt == 2)
    {
        uc_key08_led_red_04   = 0;
        uc_key08_led_green_04 = 1;
        uc_key08_led_blue_04  = 0;	
    }
    else if(uc_key08_04_led_ctrl_cnt == 3)
    {
        uc_key08_led_red_04   = 0;
        uc_key08_led_green_04 = 0;
        uc_key08_led_blue_04  = 1;	
    }
    else
    {
        uc_key08_led_red_04   = 0;
        uc_key08_led_green_04 = 0;
        uc_key08_led_blue_04  = 0;	
    }
    ul_key_04_cnt = ul_key01_01_cnt + ul_key02_01_cnt + ul_key03_01_cnt + ul_key04_01_cnt + ul_key05_01_cnt + ul_key06_01_cnt + ul_key07_01_cnt + ul_key08_01_cnt;
}
void hek1008_can0_tx_04(void)
{
    uint32_t id = HEK1008_TX_ID_04;
    uint8_t buf[8] = { 0 };
    buf[0] = (uc_key01_led_red_04  <<0) | (uc_key01_led_green_04<<2) | (uc_key01_led_blue_04 <<4)|(uc_key02_led_red_04  <<6);
    buf[1] = (uc_key02_led_green_04<<0) | (uc_key02_led_blue_04 <<2) | (uc_key03_led_red_04  <<4)|(uc_key03_led_green_04<<6);
    buf[2] = (uc_key03_led_blue_04 <<0) | (uc_key04_led_red_04  <<2) | (uc_key04_led_green_04<<4)|(uc_key04_led_blue_04 <<6);
    buf[3] = (uc_key05_led_red_04  <<0) | (uc_key05_led_green_04<<2) | (uc_key05_led_blue_04 <<4)|(uc_key06_led_red_04  <<6);
    buf[4] = (uc_key06_led_green_04<<0) | (uc_key06_led_blue_04 <<2) | (uc_key07_led_red_04  <<4)|(uc_key07_led_green_04<<6);
    buf[5] = (uc_key07_led_blue_04 <<0) | (uc_key08_led_red_04  <<2) | (uc_key08_led_green_04<<4)|(uc_key08_led_blue_04 <<6);
    buf[6] = 0;
    buf[7] = 0;
    Can0_Data_Store_Fifo(id,buf,8); 
}
uint8_t uc_hek1008_test04_status = 0;
void hek1008_test_04(void)
{
    uint8_t temp = 0;
    switch(uc_hek1008_test04_status) 
    {
        case 0:
            temp = hek1008_led_init_04();
            if(temp == 1) uc_hek1008_test04_status += 1;
            break;
        case 1:
            hek1008_key_04_redefine();
            hek1008_led_ctrl_04();
            break;
        default:
        break;
    }
}

void hek1008_run(void)
{
    hek1008_test_01();
    hek1008_test_02();
    hek1008_test_03();
    hek1008_test_04();

    hek1008_can0_tx_01();
    hek1008_can0_tx_02();
    hek1008_can0_tx_03();
    hek1008_can0_tx_04();
}



